package com.heima.search.controller.v1;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.dtos.HistorySearchDto;
import com.heima.search.pojos.ApUserSearch;
import com.heima.search.service.ApUserSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/history")
@Slf4j
@Api(value = "app端用户搜索历史记录相关接口",tags = "app端用户搜索历史记录相关接口")
public class ApUserSearchController {

    @Autowired
    private ApUserSearchService apUserSearchService;

    /**
     * 用户搜索历史
     * @return
     */
    @PostMapping("/load")
    @ApiOperation("用户搜索历史")
    public ResponseResult findUserSearch(){
        return apUserSearchService.findUserSearch();
    }

    /**
     * 删除用户历史
     * @param historySearchDto
     * @return
     */
    @PostMapping("/del")
    @ApiOperation("删除历史记录")
    public ResponseResult delUserSearch(@RequestBody HistorySearchDto historySearchDto) {

        return apUserSearchService.delUserSearch(historySearchDto);
    }
}
